﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no, email=no" />
    <link href="css/global.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="js/formValidator.js"></script>
    <!--<script src="js/checkbox.js"></script>-->
    <script src="js/jquery.messager.js"></script>
    <script src="http://static.tops001.com/kk.js"></script>
    <script src="js/Common.js"></script>
    <!--<script src="../bootstrap/iCheck-master/icheck.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../js/PageIndex2.js"></script>-->
    <script src="js/jquery.iDialog.min.js" dialog-theme="default"></script>
    <title>报备首付贷</title>
    <style type="text/css">
        body {
            background: #eeeeee;
        }

        .apply {
            margin-bottom: 20px;
        }

        .atitle {
            height: 46px;
            line-height: 46px;
            padding-left: 15px;
            background: #eeeeee;
            font-size: 16px;
            color: #666666;
            border-bottom: 1px solid #e4e4e4;
        }

        .afrom {
            padding-left: 15px;
            border-bottom: 1px solid #e4e4e4;
            background: #ffffff;
        }

            .afrom tr {
                border-bottom: 1px solid #e4e4e4;
            }

                .afrom tr:last-child {
                    border-bottom: 0 none;
                }

            .afrom th, .afrom td {
                height: 45px;
                line-height: 45px;
                font-size: 16px;
                color: #333333;
            }

            .afrom th {
                width: 120px;
                text-align: left;
            }

            .afrom tr td:last-child {
                padding-right: 15px;
            }

        .afrom_inp {
            width: 100%;
            height: 45px;
            line-height: 45px;
            border: 0 none;
            font-size: 16px;
            color: #333333;
            text-align: right;
        }

        .afrom td.unit {
            width: 35px;
            text-align: right;
        }

        .aform_set {
            width: 100%;
            height: 45px;
            position: relative;
            display: block;
        }

        .aform_finfo {
            line-height: 45px;
            font-size: 16px;
            color: #9a9a9a;
            text-align: right;
            padding-right: 35px;
        }

        .aform_arrow {
            width: 6px;
            height: 11px;
            background: url(images/arrow.png) no-repeat;
            background-size: 6px 11px;
            position: absolute;
            right: 0;
            top: 50%;
            margin-top: -5px;
            display: block;
        }

        .afoot {
            padding: 0 15px 20px 15px;
        }

        .aform_btn input {
            width: 100%;
            height: 35px;
            background: url(images/btn_1.png) repeat;
            border-radius: 3px;
            line-height: 35px;
            text-align: center;
            font-size: 16px;
            color: #ffffff;
            border: 0 none;
        }

            .aform_btn input:disabled {
                background: url(images/btn_dis.png) repeat;
                color: #bababa;
            }

        .aform_info {
            line-height: 24px;
            font-size: 13px;
            color: #909090;
        }

        .pop_warp {
            width: 230px;
            padding: 6px 20px 19px 20px;
            background: #fff;
            border-radius: 5px;
            position: absolute;
            top: 55px;
            left: 50%;
            margin-left: -134px;
            z-index: 9999;
            display: none;
        }

        .cover {
            width: 100%;
            height: 100%;
            filter: Alpha(opacity=70);
            opacity: 0.7;
            background: #000;
            position: fixed;
            top: 0;
            z-index: 999;
            display: none;
        }

        .pop_tit {
            height: 34px;
            line-height: 34px;
            border-bottom: 1px solid #e5e5e5;
            margin-bottom: 15px;
            font-size: 16px;
            color: #00aaff;
        }

        .pop_form {
            position: relative;
        }

            .pop_form tr {
                border-bottom: 1px solid #e4e4e4;
            }

            .pop_form th, .afrom td {
                height: 36px;
                line-height: 36px;
                font-size: 14px;
                color: #333333;
            }

            .pop_form th {
                width: 40px;
                text-align: left;
            }

            .pop_form tr td:last-child {
                padding-right: 15px;
            }

        .pop_inp {
            width: 100%;
            height: 36px;
            line-height: 36px;
            padding-left: 15px;
            font-size: 14px;
            color: #9a9a9a;
            border: 0 none;
        }

        .pop_btn {
            padding-left: 5px;
            padding-top: 14px;
        }

            .pop_btn .cancel {
                width: 98px;
                height: 32px;
                line-height: 32px;
                border: 1px solid #bfbfbf;
                background: #fff;
                color: #666666;
                font-size: 16px;
                float: left;
                margin-right: 16px;
                border-radius: 3px;
            }

            .pop_btn .sure {
                width: 100px;
                height: 34px;
                background: url(images/btn_1.png) repeat;
                border-radius: 3px;
                line-height: 34px;
                text-align: center;
                font-size: 16px;
                color: #ffffff;
                border: 0 none;
                float: left;
            }

        .pop_warp .form_error {
            left: 0;
            bottom: 38px;
        }
    </style>
</head>
<body>
    <div class="apply">
        <div class="atitle">贷款人信息</div>
        <div class="afrom">
            <form id="customerinfoFrm">
                <table width="100%">
                    <tr>
                        <th>贷款人（必填）</th>
                        <td><input type="text" name="CustomerName" class="afrom_inp" placeholder="请输入贷款人真实姓名" /></td>
                    </tr>
                    <tr>
                        <th>手机号（必填）</th>
                        <td><input type="text" name="MobilePhone" class="afrom_inp" placeholder="请输入贷款人手机号" /></td>
                    </tr>
                    <tr>
                        <th>身份证号</th>
                        <td><input type="text" name="IDCard" class="afrom_inp" placeholder="请输入贷款人身份证号" /></td>
                    </tr>
                </table>
            </form>
        </div>
        <div class="atitle">贷款信息</div>
        <div class="afrom">
            <form id="loaninfoFrm">
                <table width="100%">
                    <tr>
                        <th>贷款金额</th>
                        <td><input type="text" name="LoanAmount" class="afrom_inp" placeholder="请输入贷款金额" /></td>
                        <td class="unit">万元</td>
                    </tr>
                    <tr>
                        <th>购买楼盘</th>
                        <td colspan="2"><input type="text" name="BuildingName" class="afrom_inp" placeholder="请输入购买楼盘" /></td>
                    </tr>
                    <tr>
                        <th>购买房号</th>
                        <td colspan="2">
                            <a href="javascript:void(0);" class="aform_set">
                                <div class="aform_finfo">请输入购买房号</div>
                                <span class="aform_arrow"></span>
                            </a>
                        </td>
                    </tr>
                    <tr>
                        <th>房屋面积</th>
                        <td><input type="text" class="afrom_inp" id="Area" placeholder="请输入房屋面积" /></td>
                        <td class="unit">㎡</td>
                    </tr>
                    <tr>
                        <th>房源总价</th>
                        <td><input type="text" name="Amount" class="afrom_inp" placeholder="请输入房源总价" /></td>
                        <td class="unit">万元</td>
                    </tr>
                    <tr>
                        <th>报备人</th>
                        <td colspan="2"><input type="text" class="afrom_inp" name="Broker" placeholder="请输入报备人真实姓名" /></td>
                    </tr>
                    <tr>
                        <th>报备人电话</th>
                        <td colspan="2"><input type="text" name="BrokerPhone" class="afrom_inp" placeholder="请输入报备人手机号" /></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div class="afoot">
        <input type="hidden" id="Broker" />
        <input type="hidden" id="BrokerPhone" />
        <div class="aform_btn"><input type="button" onclick="Save()" value="立即申请"></div>
        <div class="aform_info">请如实填写申请信息，以便快速办理贷款</div>
    </div>
    <!--输入房号-->
    <div class="pop_warp pop_set">
        <div class="pop_tit">输入房号</div>
        <div class="pop_form">
            <table width="100%">
                <tr>
                    <th>幢</th>
                    <td><input type="text" id="Ground" class="pop_inp" placeholder="请输入楼幢号" /></td>
                </tr>
                <tr>
                    <th>单元</th>
                    <td><input type="text" id="Unit" class="pop_inp" placeholder="请输入单元号" /></td>
                </tr>
                <tr>
                    <th>室</th>
                    <td><input type="text" id="Room" class="pop_inp" placeholder="请输入房间号" /></td>
                </tr>
            </table>
            <div class="pop_btn clearfix">
                <input type="button" class="cancel" value="取消" />
                <input type="button" class="sure" value="确认" onclick="SaveHouseInfo()" />
            </div>
        </div>
    </div>
    <div class="cover"></div>
    <script>
        $(".aform_set").click(function () {
            $(".pop_set").show();
            $(".cover").show();
        })
        $(".cancel").click(function () {
            $(".pop_set").hide();
            $(".cover").hide();
        })

        //$(document).ready(function () {
        //    kk.api.jsonp("User/GetUserInfo", {}, function (data) {
        //        $("#Broker").text(data.Name || "");
        //        $("#BrokerPhone").text(data.Phone || "");
        //    });
        //});

        function SaveHouseInfo() {
            $(".aform_finfo").text($("#Ground").val() + "幢" + $("#Unit").val() + "单元" + $("#Room").val() + "室");
            $(".pop_set").hide();
            $(".cover").hide();
        }

        function Save() {
            //基本信息
            var customer = $("#customerinfoFrm").form("getData");
            customer["Marriage"] = 1;
            customer["FixedPhone"] = "";
            customer["CityID"] = 0;
            customer["Address"] = "";
            customer["BankName"] = "";
            customer["BankAccount"] = "";

            //贷款信息
            var loaninfo = $("#loaninfoFrm").form("getData");
            loaninfo["OrderID"] = 0;//订单ID
            loaninfo["LoanType"] = 5;//贷款方式：等额本息
            loaninfo["CityID"] = 0;
            loaninfo["FirstAmount"] = 0;
            loaninfo["SubNumber"] = 0;
            loaninfo["RepaymentMode"] = 5;
            loaninfo["RepaymentDay"] = 0;
            loaninfo["Remark"] = "";
            loaninfo["Agent"] = "";
            loaninfo["AgentPhone"] = "";
            loaninfo["AgentTime"] = "1900-1-1";
            loaninfo["ServiceAmount"] = 0;
            loaninfo["ServiceRatio"] = 0;
            loaninfo["ApplyTime"] = new Date();
            loaninfo["ApplyStatus"] = 4;
            loaninfo["BuildingID"] = 0;//楼盘ID，到时API替换
            loaninfo["RoomID"] = 0;//房间信息ID
            loaninfo["RoomInfo"] = $(".aform_finfo").text() + " " + $("#Area").val() + "㎡";
            //loaninfo["Broker"] = $("#Broker").text();
            //loaninfo["BrokerPhone"] = $("#BrokerPhone").text();
            if (!loaninfo["Amount"]) {
                loaninfo["Amount"] = 0;
            }
            if (!loaninfo["LoanAmount"]) {
                loaninfo["LoanAmount"] = 0;
            }
            loaninfo["Source"] = kk.queryString('source');

            var data = {};

            data["CustomerDTO"] = customer;
            data["LoanInfoDTO"] = loaninfo;

            //check data

            if (!customer["CustomerName"]) {
                $.messager.alertSuccessMsg("请输入贷款人真实姓名", 2000, false);
                //$.messager.alert("请输入贷款人真实姓名");
                return;
            }

            if (!customer["MobilePhone"]) {
                $.messager.alertSuccessMsg("请输入贷款人手机号", 2000, false);
                return;
            }

            //kk.api.jsonp("LoanInfo/SaveCustomerLoanApplyInfo", { customerLoan: JSON.stringify(data), accessToken: kk.queryString('ak') }, function (res) {
                $.messager.alertSuccessMsg("申请成功", 2000, true, function(){});
            //});
        }

    </script>
</body>
</html>
